﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using Dogshow.Win.Models;

namespace Dogshow.Win.Dialogs
{
    public partial class UnosMesta : DevExpress.XtraEditors.XtraForm
    {
        private Mesto m_Mesto;

        public UnosMesta()
        {
            InitializeComponent();
        }

        public UnosMesta(Mesto mesto) : this()
        {
            m_Mesto = mesto;
            mestoBindingSource.DataSource = mesto;
        }

        protected override void OnLoad(EventArgs e)
        {
            if (String.IsNullOrEmpty(m_Mesto.PostanskiBroj)) textEdit1.Focus();
            if (String.IsNullOrEmpty(m_Mesto.Naziv)) textEdit2.Focus();
        }

        protected override void OnClosing(CancelEventArgs e)
        {
            if (DialogResult == DialogResult.OK && !m_Mesto.Validate().IsValid)
            {
                e.Cancel = true;
            }
        }
    }
}